﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using SymulatorEthernetWPF.Shared;
using SymulatorEthernetWPF.SimObjects.Devices;

namespace SymulatorEthernetWPF.UserInterface.UIElements
{
    internal class CustomScrollViewer : ScrollViewer
    {
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            try
            {
                if (Mouse.DirectlyOver.GetType() == typeof (CustomScrollViewer))
                {
                    foreach (UIElement it in StaticVars.MainWindow.customCanvas.Children)
                    {
                        if (it.GetType().BaseType == typeof (DeviceControl))
                        {
                            ((DeviceControl) it).Deselect();
                        }
                    }
                    InfoBar.deviceControl = null;
                }
            }
            catch
            {
            }

            base.OnMouseLeftButtonDown(e);
        }

        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            StaticVars.MainWindow.ScrollViewerMouseWheel(this, e);
            //base.OnMouseWheel(e);
        }
    }
}